// 租金管理接口文档
import { api } from 'boot/axios'

/** 新增用户数：
 * name	String	是	租户姓名
 * phoneNumber	String	是	租户联系电话
 * rent	BigDecimal	是	租金金额
 * date	LocalDateTime	是	租金缴纳日期
 * isPay	String	是	是否已支付（如已支付、未支付）
 **/
export interface IRentParam {
  name?: string
  phoneNumber?: string
  rent?: number
  date?: string
  company?: string
  isPaid: string
}
export interface IEditRentParam extends IRentParam {
  tenantId: number
}

const RENT_URL = '/house/rent'
const RENT_PAGE_URL = '/house/rent/page'
const RENT_LIST_URL = '/house/rent/list'
const OVERDUEBILL_PAGE_URL = '/house/rent/overdueBills'
const RENT_REMIND_URL = '/house/rent/batchRemind'
const RENT_URGE_URL = '/house/rent/batchUrge'

// Rent
export function batchRemindRent() {
  return api.post(RENT_REMIND_URL)
}
export function batchUrgeRent() {
  return api.post(RENT_URGE_URL)
}
export function addRent(data: IRentParam) {
  return api.post(RENT_URL, data)
}
export function editRent(data: IEditRentParam) {
  return api.put(RENT_URL, data)
}
export function removeRent(id: number) {
  return api.delete(`${RENT_URL}/${id}`)
}
export function getRentById(id: number) {
  return api.get(`${RENT_URL}/${id}`)
}
export function getRentList() {
  return api.get(RENT_LIST_URL)
}

export interface IRentParams {
  company?: string
  isPaid?: number
  startDate?: string
  endDate?: string
}
export type TRentQueryParams = IPager & IRentParams
export function getRentPageList(oArg: TRentQueryParams) {
  const params: TRentQueryParams = { pageNum: oArg.pageNum || 1, pageSize: oArg.pageSize || 10 }
  if (oArg['company'] !== undefined) {
    params.company = oArg['company']
  }
  if (oArg['isPaid'] !== undefined) {
    params.isPaid = oArg['isPaid']
  }
  if (oArg['startDate'] !== undefined) {
    params.startDate = oArg['startDate']
  }
  if (oArg['endDate'] !== undefined) {
    params.endDate = oArg['endDate']
  }
  return api.get(RENT_PAGE_URL, { params })
}
export function getOverdueBillPageList(oArg: IPager) {
  const params: IPager = { pageNum: oArg.pageNum || 1, pageSize: oArg.pageSize || 10 }
  return api.get(OVERDUEBILL_PAGE_URL, { params })
}
